class Solution:
    def isValid(self, s: str) -> bool:
        if len(s) % 2:
            return False
        right = {'(', '[', '{'}
        left = {')', ']', '}'}
        stack = []
        for c in s:
            if c in right:
                stack.append(c)
            if c in left:
                if len(stack) == 0:
                    return False
                r_c = stack.pop()
                print(r_c, "--", c)
                if (c == ')' and r_c == '(') or (c == ']' and r_c == '[') or (c == '}' and r_c == '{'):
                    continue
                stack.append(r_c)
                stack.append(c)
        if stack:
            return False
        return True


# print(Solution().isValid('([}}])'))


